/*
  Copyright (C) 2011, Kyungjoo Kim
  
  This file is part of UHM (Unassembled HyperMatrix) sparse direct solver.
  
  All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  Also add information on how to contact you by electronic and paper mail.
  
  
  Kyungjoo Kim
  iamkyungjoo@gmail.com
*/
#ifndef UHM_UTIL_HXX
#define UHM_UTIL_HXX

#undef FORT
#define FORT(i) (i-1)

#define UHM_C2F(name) name ## _

#define UHM_ERROR(eval, msg) \
  linal::error((eval),__FILE__,__LINE__,"[UHM ERROR] ", "%s\n", msg);

#define UHM_ERROR_DETAIL(eval,format,...) \
  linal::error((eval), __FILE__,__LINE__,"[UHM ERROR] ", format, __VA_ARGS__);

namespace uhm {
  // ----------------------------------------------------------------
  // ** Timer
  extern double timer();

  // ----------------------------------------------------------------
  // ** Offset
  extern void reset_g_offset();
  extern void add_g_offset(int offset);
  extern int  get_g_offset();

  // ----------------------------------------------------------------
  // ** Query
  extern bool is_hier_matrix_enable();
  extern bool is_multithreading_enable();

  // ----------------------------------------------------------------
  // ** Multithreading
  extern void set_num_threads(int nt);
  extern int  get_num_threads();

  // ----------------------------------------------------------------
  // ** File IO
  extern void  set_ooc_dir(char*dir);
  extern char* get_ooc_dir();

  extern bool read_line  (FILE *fp, char **line_out);
  extern bool open_file  (char *fullpath, char *mode, FILE **fp);
  extern bool close_file (FILE *fp);
  extern bool is_file(char *fullpath);
  extern bool is_dir(char *path);
  extern bool make_dir(char *path, int mode);
  extern bool remove_dir(char *path);
  extern bool create_file(char *fullpath);
  extern bool delete_file(char *fullpath);
  extern bool write_buffer_to_file(FILE *fp, long buf_size, char *buf);
  extern bool read_buffer_from_file(FILE *fp, long buf_size, char *buf);



}


#endif
